package org.yoki.edu.common.protocol.radius.enums;

import lombok.Getter;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2017/12/14$ 16:13$
 */
public enum RadiusAttrTypeEnum {

    /**
     * 1      User-Name
     * 2      User-Password
     * 3      CHAP-Password
     * 4      NAS-IP-Address
     * 5      NAS-Port
     * 6      Service-Type
     * 7      Framed-Protocol
     * 8      Framed-IP-Address
     * 9      Framed-IP-Netmask
     * 10      Framed-Routing
     * 11      Filter-Id
     * 12      Framed-MTU
     * 13      Framed-Compression
     * 14      Login-IP-Host
     * 15      Login-Service
     * 16      Login-TCP-Port
     * 17      (unassigned)
     * 18      Reply-Message
     * 19      Callback-Number
     * 20      Callback-Id
     * 21      (unassigned)
     * 22      Framed-Route
     * 23      Framed-IPX-Network
     * 24      State
     * 25      Class
     * 26      Vendor-Specific
     * 27      Session-Timeout
     * 28      Idle-Timeout
     * 29      Termination-Action
     * 30      Called-Station-Id
     * 31      Calling-Station-Id
     * 32      NAS-Identifier
     * 33      Proxy-State
     * 34      Login-LAT-Service
     * 35      Login-LAT-Node
     * 36      Login-LAT-Group
     * 37      Framed-AppleTalk-Link
     * 38      Framed-AppleTalk-Network
     * 39      Framed-AppleTalk-Zone
     * 40-59   (reserved for accounting)
     * 60      CHAP-Challenge
     * 61      NAS-Port-Type
     * 62      Port-Limit
     * 63      Login-LAT-Port
     */

    userName(1),
    userPassword(2),
    chapPassword(3),
    nasIpAddress(4),
    nasPort(5),

    serviceType(6),
    framedProtocol(7),
    framedIpAddress(8),
    framedIpNetMask(9),
    framedRouting(10),

    filterId(11),
    framedMTU(12),
    framedCompression(13),
    LoginIpHost(14),
    LoginService(15),

    LoginTcpPort(16),
    replyMessage(18),
    callbackNumber(19),
    callbackId(20),

    framedRoute(22),
    framedIPXNetwork(23),
    state(24),
    classType(25),

    vendorSpecific(26),
    sessionTimeout(27),
    idleTimeout(28),
    terminationAction(29),
    calledStationId(30),

    callingStationId(31),
    nasIdentifier(32),
    proxyState(33),
    loginLatService(34),
    loginLATNode(35),

    loginLATGroup(36),
    framedAppleTalkLink(37),
    framedAppleTalkNetwork(38),
    framedAppleTalkZone(39),

    /**
     * accounting part start
     * 1-39   (refer to RADIUS document [2])
     * 40      Acct-Status-Type
     * 41      Acct-Delay-Time
     * 42      Acct-Input-Octets
     * 43      Acct-Output-Octets
     * 44      Acct-Session-Id
     * 45      Acct-Authentic
     * 46      Acct-Session-Time
     * 47      Acct-Input-Packets
     * 48      Acct-Output-Packets
     * 49      Acct-Terminate-Cause
     * 50      Acct-Multi-Session-Id
     * 51      Acct-Link-Count
     * 60+     (refer to RADIUS document [2])
     */
    acctStatusType(40),
    acctDelayTime(41),
    acctInputOctets(42),
    acctOutputOctets(43),
    acctSessionId(44),
    acctAuthentic(45),

    acctSessionTime(46),
    acctInputPackets(47),
    acctOutputPackets(48),
    acctTerminateCause(49),
    acctMultiSessionId(50),

    acctLinkCount(51),

    /**
     * accounting part end
     */

    chapChallenge(60),
    nasPortType(61),
    portLimit(62),
    loginLATPort(63);

    @Getter
    private Integer type;

    RadiusAttrTypeEnum(Integer type) {
        this.type = type;
    }

    public static RadiusAttrTypeEnum getByTypeCode(Integer type) {
        if (null == type) {
            return null;
        }
        RadiusAttrTypeEnum[] enums = RadiusAttrTypeEnum.values();
        for (RadiusAttrTypeEnum radiusAttrTypeEnum : enums) {
            if (radiusAttrTypeEnum.getType().intValue() == type.intValue()) {
                return radiusAttrTypeEnum;
            }
        }
        return null;
    }

}
